//
//  HotCityTableViewCell.m
//  EasyToTesco2.0
//
//  Created by baozi on 16/8/23.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "HotCityTableViewCell.h"
#import "StandButton.h"

@implementation HotCityTableViewCell

- (void)setHotCityArray:(NSArray *)HotCityArray {
    _HotCityArray = HotCityArray;
    
    for (int i = 0; i < HotCityArray.count; i++) {
        CGFloat margin = 16;
        CGFloat HeightMargin = 8;
        CGFloat w = (WIDTH - margin * 4) / 3;
        CGFloat h = 35;
        
        StandButton *hotCityButton = [[StandButton alloc] init];
        hotCityButton.backgroundColor = [UIColor whiteColor];
        [hotCityButton setTitle:HotCityArray[i] forState:UIControlStateNormal];
        [hotCityButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        hotCityButton.tag = i;
        [hotCityButton addTarget:self action:@selector(HotCityButton:) forControlEvents:UIControlEventTouchUpInside];
        int row=i/3;//行号
        int loc=i%3;//列号
        hotCityButton.titleLabel.font = [UIFont systemFontOfSize:15];
        CGFloat appviewx=margin+(margin+w)*loc;
        CGFloat appviewy=HeightMargin+(HeightMargin+h)*row;
        
        [hotCityButton setFrame:CGRectMake(appviewx, appviewy, w, h)];
        [self.contentView addSubview:hotCityButton];
    }
}

- (void)HotCityButton:(UIButton *)button {
    if ([self.delegate respondsToSelector:@selector(didClickHotCityButton:)]) {
        [self.delegate didClickHotCityButton:button];
    }
}

@end
